const express = require('express');
function getDateTime(time) {
  // 2016-08-24 15:35
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var hh = time.getHours();
  var mm = time.getMinutes();
  var ss = time.getSeconds();
  m = m < 10 ? `0${m}` : m;
  d = d < 10 ? `0${d}` : d;
  hh = hh < 10 ? `0${hh}` : hh;
  mm = mm < 10 ? `0${mm}` : mm;
  ss = ss < 10 ? `0${ss}` : ss;
  return `${y}-${m}-${d} ${hh}:${mm}`;
}
function getDateNoYear(time) {
  // 08-24
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var hh = time.getHours();
  var mm = time.getMinutes();
  var ss = time.getSeconds();
  m = m < 10 ? `0${m}` : m;
  d = d < 10 ? `0${d}` : d;
  hh = hh < 10 ? `0${hh}` : hh;
  mm = mm < 10 ? `0${mm}` : mm;
  ss = ss < 10 ? `0${ss}` : ss;
  return `${m}-${d}`;
}
function getDateLastYear(time) {
  // 08-25 / 2018
  var y = time.getFullYear();
  var m = time.getMonth() + 1;
  var d = time.getDate();
  var hh = time.getHours();
  var mm = time.getMinutes();
  var ss = time.getSeconds();
  m = m < 10 ? `0${m}` : m;
  d = d < 10 ? `0${d}` : d;
  hh = hh < 10 ? `0${hh}` : hh;
  mm = mm < 10 ? `0${mm}` : mm;
  ss = ss < 10 ? `0${ss}` : ss;
  return `${m}-${d} / ${y}`;
}

module.exports = { getDateTime, getDateNoYear, getDateLastYear };
